<?php

namespace app\admin\controller;

use think\Controller;
use think\Db;
use think\Request;
use think\Session;

class Login extends Controller
{

    public function urllogin(Request $request)
    {
        $id=$request->get('id');
        $c=$request->get('c');
        $sign=$request->get('sign');
        if(md5('lc'.$c.$id)!=$sign){
            return '你想干啥';die;
        }
        if($c=='user'){
            // user
            $user=Db::name('users')->field('id,phonenumber')->find($id);
            Session::set('uid', $user['id']);
            Session::set('phonenumber', $user['phonenumber']);
            Session::set('codes', mt_rand(1000, 9999));
            $this->redirect('home/Center/index');
        }
       if($c=='vip'){
           // vip
           $res=Db::name('vip')->field('id,status,name,password,phonenumber')->find($id);
           Session::set('user',$res);
           $this->redirect('vip_agent/Index/showindex');
       }


        if($c=='agent'){
            // agent
            $res=Db::name('agents')->field('id,status,name,password,phonenumber')->find($id);
            Session::set('agents',$res);
            $this->redirect('agent/Index/index');
        }

        if($c=='cms'){
            $res=Db::name('admin_user')->field(true)->find($id);
            Session::set('cms',$res);
            $url=$request->get('url');
            $this->redirect($url);
        }

    }

}
